package top.tsyz.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import top.tsyz.entity.OrderItem;
import top.tsyz.service.IOrderItemService;

import java.util.List;

/**
 * OrderItemController控制器
 */
@RestController
@RequestMapping("/api/orderItems")
@Api(tags = "OrderItem管理接口")
public class OrderItemController {

    @Autowired
    private IOrderItemService iorderitemservice;

    @GetMapping("/list")
    @ApiOperation("获取所有OrderItem")
    public List<OrderItem> list() {
        return iorderitemservice.list();
    }

    @GetMapping("/{id}")
    @ApiOperation("根据ID获取OrderItem")
    public OrderItem getById(@PathVariable Long id) {
        return iorderitemservice.getById(id);
    }

    @PostMapping
    @ApiOperation("新增OrderItem")
    public boolean save(@RequestBody OrderItem orderitem) {
        return iorderitemservice.save(orderitem);
    }

    @PutMapping
    @ApiOperation("更新OrderItem")
    public boolean update(@RequestBody OrderItem orderitem) {
        return iorderitemservice.updateById(orderitem);
    }

    @DeleteMapping("/{id}")
    @ApiOperation("删除OrderItem")
    public boolean delete(@PathVariable Long id) {
        return iorderitemservice.removeById(id);
    }
}
